<template>
	<view class="Image">
		<yzt-Input :fun="getImages" class="ipt">搜索</yzt-Input>
		<scroll-view class="scroll" scroll-y="true">
			<view class="imgs">
				<yzt-Image
				v-for="item in ImgArr"
				:url="[item.contentUrl,item.contentUrl]"
				:key="item.name"
				/>
			</view>
		</scroll-view>
	</view>
</template>

<script lang="ts" setup>
	import { Ajax , Value} from '@/type/type';
	import { onMounted, ref } from "vue";
	const ImgArr = ref<Value[]>([]);
	const getImages = (name:string)=>{
		if(name.length > 1){
			uni.showLoading({title:'加载中...',mask:true});
			Ajax({
				url:'https://cn.bing.com/images/api/custom/search',
				header:{
					"cookie":"ipv6=hit=1677592110921&t=4; _EDGE_V=1; MUID=294BD8D2D0786CFF080DCA4DD13B6DD1; MUIDB=294BD8D2D0786CFF080DCA4DD13B6DD1; USRLOC=HS=1&CLOC=LAT=24.369725355395534|LON=106.86745002252654|A=733.4464586120832|TS=230228134817|SRC=W; SRCHD=AF=NOFORM; SRCHUID=V=2&GUID=C82E0F8A816846508F67234CA0237A6A&dmnchg=1; ANON=A=F993AC31E3C4568382432869FFFFFFFF; SnrOvr=X=rebateson; MMCASM=ID=2A17569CD1324C12A7F0A588A3B7BD2A; WLS=C=4a833f23086b4aaa&N=%e6%b6%9b; SRCHS=PC=U531; btstkn=jFU%252F3ageahbyPfoigu2OjW0OjzIir4W6EWzBCM69sYBjvwkWZe4oGbzJuaUDnjSXQUgwD%252BgXOdT4x8TdNJ3CYNRkmWrj%252BDRes84MpsL08Ss%253D; ZHCHATWEAKATTRACT=TRUE; _SS=SID=34B73E6532A460F7244D2CA333E76115&PC=U531&R=1248&RB=1248&GB=0&RG=0&RP=1248; ZHCHATSTRONGATTRACT=TRUE; ENSEARCH=BENVER=0; fbar=imgfbar=1; ABDEF=V=13&ABDV=11&MRNB=1677591810499&MRB=0; _UR=QS=0&TQS=0; MicrosoftApplicationsTelemetryDeviceId=8e33f95b-77ef-46db-bb0f-b1b9e7e710d4; _ITAB=STAB=TR; SUID=A; _TTSS_IN=hist=WyJlbiIsInpoLUhhbnMiLCJhdXRvLWRldGVjdCJd; _TTSS_OUT=hist=WyJ6aC1IYW5zIiwiZW4iXQ==; _tarLang=default=en; _U=1rih3iuUwZPXebEjDN42AFcdA1Q6sEqRMGvWRt6Pkd3MRhd9LUkC-CA7qF8gPylAOcw4TTheRr62umB8MTLquiBBsIV1Uq5yt96T0s9P888lckAWVKuXFkohfeS6Xxs1K_aGYyVDv7FPkYBZo2lDRUGjAd4KJMPwTrTo2Pm8I-L2_s6YmwihRxlDQH8mmWEzMVMZ7F0uhfNt7SqvI2FjEsv0C6TyQRvoqqvQpPj48vpw; SRCHUSR=DOB=20230221&T=1677596214000; ipv6=hit=1677599815417&t=4; ANIMIA=FRE=1; _EDGE_CD=u=zh-hans; _EDGE_S=SID=34B73E6532A460F7244D2CA333E76115&ui=zh-cn; SNRHOP=I=&TS=; _HPVN=CS=eyJQbiI6eyJDbiI6MSwiU3QiOjAsIlFzIjowLCJQcm9kIjoiUCJ9LCJTYyI6eyJDbiI6MSwiU3QiOjAsIlFzIjowLCJQcm9kIjoiSCJ9LCJReiI6eyJDbiI6MSwiU3QiOjAsIlFzIjowLCJQcm9kIjoiVCJ9LCJBcCI6dHJ1ZSwiTXV0ZSI6dHJ1ZSwiTGFkIjoiMjAyMy0wMi0yOFQwMDowMDowMFoiLCJJb3RkIjowLCJHd2IiOjAsIkRmdCI6bnVsbCwiTXZzIjowLCJGbHQiOjAsIkltcCI6OH0=; ai_session=wlmyV/Us3rry0TwA1CZVCF|1677598474550|1677598474550; _RwBf=r=1&mta=0&rc=1248&rb=1248&gb=0&rg=0&pc=1248&mtu=0&rbb=0.0&g=0&cid=&clo=0&v=72&l=2023-02-28T08:00:00.0000000Z&lft=0001-01-01T00:00:00.0000000&aof=0&o=0&p=None&c=MA13C5&t=2653&s=2022-03-10T15:28:10.5729054+00:00&ts=2023-02-28T15:34:46.2736419+00:00&rwred=0&wls=0&lka=0&lkt=0&TH=&e=T-VqMJ3E7isRZDXCHsWU0ADNqhyH8LReWT1FfUjJBguBWJHYbiTMVacfxqYkePOX72li4QA2yI7tDCO3oLO20YPfWit7qH8-sJ7D3jOidI0&A=; SRCHHPGUSR=SRCHLANG=zh-Hans&PV=10.0.0&BZA=0&BRW=HTP&BRH=M&CW=882&CH=754&SCW=882&SCH=754&DPR=1.3&UTC=480&DM=0&EXLTT=31&PRVCW=882&PRVCH=754&HV=1677598486"
				},
				data:{
					q:name,
					count:25,
					skey:"N4LWdB9CCGfR3Xz2YnDkCGT-yZm3zk54nYfUqou7fNc"
				},
				dataType:"json",
			}).then(res=>{
				ImgArr.value = [];
				setTimeout(()=>{
					ImgArr.value = res.value;
					uni.hideLoading()
				},500)
			})
		}
	}
	onMounted(()=>getImages('图片'));
</script>

<style lang="scss" scoped>
	.Image{
		display: flex;
		flex-direction: column;
		.scroll{
			margin-top: 10rpx;
			height: 85vh;
			.imgs{
				width: 100%;
				display: grid;
				gap: $bor;
				grid-template-columns: auto auto;
			}
		}
	}
</style>
